<extend name="template/base_index" />


<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <div class="h4">提现历史查询</div>

            <div class="filter-controls">
                <form class="form-inline searchForm" method="post" action="{:U('Admin/Withdraw/query')}">
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i>提现用户</div>
                            <select id="user_select2" name="uid" class="form-control">
                                <if condition="$uid gt 0"><option value='{$uid}' selected="selected">[id:{$uid}] {$nickname}</option></if>
                            </select>
                        </div>
                    </div>
                    <div class="form-group ">
                    <div class="input-group">
                        <div class="input-group-addon">时间<i class="fa fa-calendar"></i></div>
                        <input type="text" name="startdatetime" id="startdatetime" class="form-control input-short" value="{:date('Y-m-d H:i:s',$startdatetime)}" />
                        <div class="input-group-addon">
                            <i class="fa fa-long-arrow-right"></i>
                        </div>
                        <input type="text" name="enddatetime" id="enddatetime" class="form-control input-short" value="{:date('Y-m-d H:i:s',$enddatetime)}" />
                    </div>
                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
                    </div>
                </form>
            </div>

            <div class="table-responsive">
                <table class="table table-bordered table-striped table-condensed table-hover table-condensed">
                     <thead>
                      <th>ID</th>
                      <th>用户ID</th>
                      <th>变动详情</th>
                      <th>变动前金额</th>
                      <th>+金额</th>
                      <th>-金额</th>
                      <th>变动后金额</th>
                      <th>变动时间</th>
                    </thead>
                    <tbody>
                    <volist name="list" id="vo">
                    <tr>
                    	<td>{$vo.id}</td>
                        <td><a href="{:U('Admin/CustomerInfo/info',array('id'=>$vo['uid']))}">{$vo.uid}</a></td>
                        <td>{$vo.reason}</td>
                        <td>{$vo.before_money}</td>
                        <td>{$vo.plus}</td>
                        <td>{$vo.minus}</td>
                        <td>{$vo.after_money}</td>
                        <td>
                        <if condition="$vo['wallet_type'] eq 0">
                            <font color="green">流动</font>
                        <elseif condition="$vo['wallet_type'] eq 1" />
                            <font color="red">冻结资金</font>
                        <else />
                            <font color="pink">未知</font>
                        </if>
                        </td>
                        <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                    </tr>
                    </volist>
                    </tbody>
                </table>
                <div>{$show}</div>
            </div>

        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">
    <script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
    <script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
    <script type="text/javascript">
        $(function(){
            $('#startdatetime').datetimepicker({
                lang: 'ch',
                format:'Y-m-d',
                timepicker:false,
            });
            $('#enddatetime').datetimepicker({
                lang: 'ch',
                format:'Y-m-d',
                timepicker:false,
            });
            $(".status").click(function(){
                $(".searchForm").submit();
            })
            $("#user_select2").select2({
                placeholder: "输入用户id或昵称查询"	,
                language: "zh-CN",
                ajax: {
                    url: "{:U('Admin/Member/select')}",
                    dataType: 'json',
                    delay: 250,
                    data: function (params) {
                        var queryParameters = {
                            q: params.term
                        }
                        return queryParameters;

                    },
                    processResults: function (data, page) {
                        if(!data.info){
                            data.info = new Array();
                            data.info['nodata']="无相关数据";
                        }
                        // parse the results into the format expected by Select2.
                        // since we are using custom formatting functions we do not need to
                        // alter the remote JSON data
                        return {
                            results: data.info
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                templateSelection: function (repo) {
                    return repo.nickname ? '[id:'+repo.id+'] '+repo.nickname: repo.text;
                },
                templateResult: function (repo) {

                    if (repo.loading) return repo.text;
                    if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                    var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                    return $(markup);
                },
            });
        });
    </script>
</block>